/**************************************************************************
** Yabet is bloging editor tool that supports many blog's formats. It is very usefull for crossposting, allows easily to
** make posts to your blogs.
**
** Copyright (C) 2010 Valery Konchin <eeexception@gmail.com>
**
** This program is free software: you can redistribute it and/or modify
**     it under the terms of the GNU General Public License as published by
**     the Free Software Foundation, either version 3 of the License, or
**     (at your option) any later version.
**
**     This program is distributed in the hope that it will be useful,
**     but WITHOUT ANY WARRANTY; without even the implied warranty of
**     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**     GNU General Public License for more details.
**
**     You should have received a copy of the GNU General Public License
**     along with this program.  If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/

#ifndef YABET_H
#define YABET_H

#include <QString>
#include <QObject>
#include "ImageUploader.h"
#include <QTextDocument>
#include <markupmanager.h>
#include "yabettextmarkup.h"
#include "googletranslater.h"
#include "yabetloghandler.h"
#include "yabetversion.h"
#include "imageshackimageuploader.h"

class Yabet : public QObject
{
    Q_OBJECT

public:
    Yabet();
    void setDefaultMarkup(YabetTextMarkup *markup);
    void setCurrentMarkup(YabetTextMarkup *markup);
    YabetTextMarkup* getDefaultMarkup();
    YabetTextMarkup* getCurrentMarkup();
    void setEditorText(QTextDocument * document);
    void insertCode(int from, QString textToModify);
    void insertBulletList(int from, QString textToModify);
    void convertHtmlTags(int from, int to);
    QString getText();
    void setTopic(QString topic);
    void setFilename(QString filename);
    QString getFilename();
    bool isChanged();
    void change(bool change);
    QString getTopic();
    MarkupManager* getMarkupManager();
    GoogleTranslater* getGoogleTranslater();
    void translateText(QString text, QString fromLanguage, QString toLanguage, int from);
    void modifyText(QString markupElementName, int from, QString textToModify);
    void modifyText(QString markupElementName, int from, int to, QStringList textsToModify);
    QString getVersion();
    QString getBuildDate();
    void openFile(QString filename);
    void saveFile(QString filename);
    void newFile();
    QString uploadImage(QString fileName, QString fileHosting);
    ImageShackImageUploader *imageUploader;
private:
    static const YabetLogHandler *log;
    YabetTextMarkup *defaultMarkup;
    YabetTextMarkup *currentMarkup;
    bool changed;
    QString topic;
    QString filename;
    QTextDocument *document;
    QString formattedText;
    MarkupManager *manager;
    GoogleTranslater *gTranslater;
    void insertText(QString text, int from);
    QString htmlStart;
    QString htmlStop;
signals:
    void wasError(QString msg);
    void wasWarning(QString msg);
    void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
};

#endif // YABET_H
